<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户详情</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}"
          rel="stylesheet">
    <!-- Morris -->
    <link href="http://cdn.viptool.cn/lib/morris.js/0.4.3/morris.css" rel="stylesheet">
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>
    <link href="../../resource/lib/imageview/css/imageviewer.css"
          th:href="@{/resource/lib/imageview/css/imageviewer.css}" rel="stylesheet"/>

    <script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
    <script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
    <script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316"
            th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316(123123)}"></script>
    <script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316"
            th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-init.js}"></script>
    <style>
        .user-close-config {
            height: 40px;
            line-height: 40px;
        }

        .user-close-config .control-label {
            margin-left: 20px;
            font-weight: normal !important;
        }

        .user-close-config label.off {
            background-color: red;
            color: #fff;
            margin-right: 10px;
        }

        .user-close-config label.on {
            background-color: #fff;
            color: #674646;
            border: 1px solid #ccc;
            margin-right: 10px;
        }

        .separator {
            margin: 31px 20px 10px 20px;
            border-bottom: 1px solid #ccc;
        }
    </style>
</head>

<body>
<div class="wrapper wrapper-content tooltip-demo">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div th:replace="fragments/live_fragment::roomDetailFg" class="ibox-title"
                     style="vertical-align: bottom;height: 100%;padding-left: 0;">
                    <h5 style="font-size: 18px;">
                        <img src="../../resource/img/p2.jpg" onerror="this.src='../../resource/img/d_head.jpeg'"
                             alt="" style="width:100px;height:100px;"/>
                    </h5>
                    <div style="margin-left: 120px;width: 50%;margin-top: -6px;">
                        <h3>剑南的直播间</h3>
                        <p style="width: 373px;height: 51px;">
                            非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间</p>
                        <p>创建时间：2012-12-12 12:12:12</p>
                    </div>
                    <button type="button" onclick="liveHandler.edit()"
                            style="float: right;margin-top: -45px;margin-right: 10px;"
                            class="btn btn-primary btn-xl m-b-none">房间设置
                    </button>
                </div>
                <div class="tabs-container" style="margin-top: 20px;">
                    <ul class="nav nav-tabs">
                        <li>
                            <a th:href="@{/live/detail/products(roomId=${room.id})}" href="user_detail.html">商品管理</a>
                        </li>
                        <li>
                            <a th:href="@{/live/detail/directors(roomId=${room.id})}"
                               href="../user/user_detail_advance_log.html">主播管理</a>
                        </li>
                        <li class="active">
                            <a th:href="@{/live/detail/sessions(roomId=${room.id})}"
                               href="../user/user_detail_advance_log.html">直播记录</a>
                        </li>
                        <li>
                            <a th:href="@{/live/detail/videos(roomId=${room.id})}"
                               href="../user/user_detail_advance_log.html">直接间视频</a>
                        </li>
                        <li sec:authorize="hasRole('ADMIN')">
                            <a th:href="@{/live/detail/images(roomId=${room.id})}"
                               href="../live/live_detail_images.html">直接间图片</a>
                        </li>
                        <li sec:authorize="hasRole('ADMIN')">
                            <a th:href="@{/live/detail/users(roomId=${room.id})}"
                               href="../user/user_detail_advance_log.html">直接间用户列表</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body">
                                <div>
                                    <form id="saveForm">
                                        <input type="hidden" th:value="${pageIndex}" name="pageIndex"/>
                                    </form>
                                    <!--                                    <div class="form-inline" style="padding-bottom: 15px;text-align: right;">-->
                                    <!--                                        <button type="button" onclick="liveHandler.createModalShow(1)"-->
                                    <!--                                                class="btn btn-primary btn-sm m-b-none">添加预告-->
                                    <!--                                        </button>-->
                                    <!--                                    </div>-->
                                    <div class="table-responsive">

                                        <table class="table table-bordered table-hover table-center">
                                            <thead>
                                            <tr>
                                                <th>直播编号</th>
                                                <th>直播房间</th>
                                                <th>主播</th>
                                                <!--                                            <th>预告时间</th>-->
                                                <th>直播时间</th>
                                                <th>直播时常</th>
                                                <th>成交订单数</th>
                                                <th>成交金额</th>
                                                <th:block sec:authorize="hasRole('ADMIN')">
                                                    <th>最高在线人数</th>
                                                    <th>观看人数</th>
                                                    <th>人均时长</th>
                                                </th:block>
                                                <th>活跃度</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr th:each="item:${sessions}">
                                                <td th:text="${item.id}">123123123</td>
                                                <td th:text="${item.sessionTitle}"></td>
                                                <td th:text="${item.liveDirectorPO.directorName}"></td>
                                                <!--                                            <td>-->
                                                <!--                                                <span th:if="${item.foreshowTime!=null}"-->
                                                <!--                                                      th:text="${#temporals.format(item.foreshowTime,'yyyy-MM-dd HH:mm:ss')}"></span>-->
                                                <!--                                            </td>-->
                                                <td th:text="${#temporals.format(item.startTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                                <td th:text="${item.liveDuration()}"></td>
                                                <th:block th:if="${item.playStatus.code==0}">
                                                    <td th:text="${item.statisticsDTO.dealNum}"></td>
                                                    <td th:text="${item.statisticsDTO.dealAmount}"></td>
                                                    <th:block sec:authorize="hasRole('ADMIN')">
                                                        <td th:text="${item.statisticsDTO.maxOnlineNum}"></td>
                                                        <td th:text="${item.statisticsDTO.grandTotalNum}"></td>
                                                        <td th:text="${item.statisticsDTO.avgDuration}"></td>
                                                    </th:block>
                                                    <td th:text="${item.statisticsDTO.activityNum}"></td>
                                                </th:block>
                                                <th:block th:if="${item.playStatus.code!=0}">
                                                    <td th:text="${item.dealNum}"></td>
                                                    <td th:text="${item.dealAmount}"></td>
                                                    <th:block sec:authorize="hasRole('ADMIN')">
                                                        <td th:text="${item.maxOnlineNum}"></td>
                                                        <td th:text="${item.currentMaxVisits}"></td>
                                                        <td th:text="${item.avgDuration}"></td>
                                                    </th:block>
                                                    <td th:text="${item.activityNum}"></td>
                                                </th:block>
                                                <td>
                                                    <th:block th:if="${item.playStatus.code==1}">
                                                        <input type="hidden" name="sessionTitle"
                                                               th:id="${'sessionTitle'+item.id}"
                                                               th:value="${item.sessionTitle}"/>
                                                        <input type="hidden" name="directorId"
                                                               th:id="${'directorId'+item.id}"
                                                               th:value="${item.liveDirectorPO.id}"/>
                                                        <input th:if="${item.foreshowTime!=null}" type="hidden"
                                                               name="foreshowTime" th:id="${'foreshowTime'+item.id}"
                                                               th:value="${#temporals.format(item.foreshowTime,'yyyy-MM-dd HH:mm:ss')}"/>
                                                        <input type="hidden" name="foreshowDesc"
                                                               th:id="${'foreshowDesc'+item.id}"
                                                               th:value="${item.foreshowDesc}"/>
                                                        <button onclick="liveHandler.createModalShow(1)"
                                                                th:onclick="liveHandler.createModalShow([[${item.id}]])"
                                                                type="button"
                                                                class="btn btn-primary btn-xs m-b-none">修改
                                                        </button>
                                                        <button onclick="liveHandler.delete(1)"
                                                                th:onclick="liveHandler.delete([[${item.id}]])"
                                                                type="button"
                                                                class="btn btn-danger btn-xs m-b-none"
                                                                style="margin-left: 5px;">删除
                                                        </button>
                                                    </th:block>
                                                    <th:block th:if="${item.playStatus.code==0}">
                                                        <button onclick="liveHandler.stop(1)"
                                                                th:onclick="liveHandler.stop([[${item.id}]])"
                                                                type="button"
                                                                class="btn btn-danger btn-xs m-b-none"
                                                                style="margin-left: 5px;">关闭
                                                        </button>
                                                    </th:block>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <p style="float: left; margin: 20px 0;">
                                        共<span th:text="${totalRecords}"></span>条记录，当前第<span
                                            th:text="${pageIndex}"></span>/<span
                                            th:text="${totalPages==0?1:totalPages}"></span>，每页20条记录
                                    </p>
                                    <ul style="float: right;" class="pagination pagination-split">
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="create_session_template">
    <div class="form-horizontal" style="width: 600px;">
        <input type="hidden" id="create_session_id"/>
        <div class="form-group">
            <label class="col-sm-2 control-label">选择主播:</label>

            <div class="col-sm-10">
                <select style="width: auto;" class="form-control input-sm" id="create_directorId">
                    <option th:each="director:${directors}" th:value="${director.id}"
                            th:text="${director.directorName}">请选择
                    </option>
                </select>
            </div>
        </div>
        <div class="hr-line-dashed "></div>
        <div class="form-group">
            <label class="col-sm-2 control-label">直播标题:</label>

            <div class="col-sm-10">
                <textarea id="create_sessionTitle" rows="4" class="form-control" placeholder="直播标题"></textarea>
            </div>
        </div>
        <div class="hr-line-dashed "></div>
        <div class="form-group">
            <label class="col-sm-2 control-label">预告时间:</label>

            <div class="col-sm-10">
                <div style="width: 200px" class='input-group date'>
                    <input type="text" class="form-control input-sm m-b-none" id="create_foreshowTime"
                           placeholder="预告时间"
                           onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
        <div class="hr-line-dashed "></div>
        <div class="form-group">
            <label class="col-sm-2 control-label">预告描述:</label>

            <div class="col-sm-10">
                <textarea id="create_foreshowDesc" rows="4" class="form-control" placeholder="预告描述"></textarea>
            </div>
        </div>
    </div>
</script>


<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>
<script src="../../resource/lib/imageview/js/imageviewer.min.js"
        th:src="@{/resource/lib/imageview/js/imageviewer.min.js}"></script>
<script src="../../resource/lib/My97DatePicker/WdatePicker.js"
        th:src="@{/resource/lib/My97DatePicker/WdatePicker.js}"></script>
<script type="text/javascript" th:inline="javascript">
    const pageIndex = /*[[${pageIndex}]]*/  1;
    const totalPages = /*[[${totalPages}]]*/  0;
    const pageUri = /*[[@{/live/detail/sessions}]]*/  "";
    const apiUri = /*[[@{/live/detail/sessions}]]*/  "";
</script>

<script type="text/javascript">
    var createModal = $("#create_session_template").modal("新建直播预告", function () {
        liveHandler.create();
    });
    $(function () {
        //初始化分页
        var pageinate = new hot.paging(".pagination", pageIndex, totalPages, 7);

        pageinate.init(function (p) {
            liveHandler.search(p);
        });
    });

    var liveHandler = {
        search: function (pageIndex) {
            let roomId = $("#hdRoomId").val();
            window.location.href = pageUri + "?roomId=" + roomId + "&pageIndex=" + pageIndex;
        },
        createModalShow: function (id) {
            createModal.show(function () {
                $("#create_foreshowTime").datetimepicker({
                    autoclose: true,
                    format: 'yyyy-mm-dd hh:ii:ss'
                });
            });

            $("#create_session_id").val(id);
            if (id > 0) {
                $("#create_directorId").val($("#directorId" + id).val());
                $("#create_foreshowDesc").val($("#foreshowDesc" + id).val());
                $("#create_foreshowTime").val($("#foreshowTime" + id).val());
                $("#create_sessionTitle").val($("#sessionTitle" + id).val());
            }
        },
        create: function () {
            let sessionId = $("#create_session_id").val();
            let directorId = $("#create_directorId").val();
            let sessionTitle = $("#create_sessionTitle").val();
            let foreshowTime = $("#create_foreshowTime").val();
            let foreshowDesc = $("#create_foreshowDesc").val();

            let requestData = {
                id: sessionId,
                directorId: directorId,
                foreshowTime: foreshowTime,
                foreshowDesc: foreshowDesc,
                sessionTitle: sessionTitle
            };

            hot.ajax(apiUri + "/create", requestData, function (apiResult) {
                if (apiResult.resultCode === 2000) {
                    hot.tip.success("操作成功", function () {
                        window.location.reload();
                    })
                } else {
                    hot.tip.error("操作失败--" + apiResult.resultMsg);
                }
            }, function () {
            }, "post", 300);
        },
        delete: function (id) {
            hot.confirm("确定删除该场次", function () {
                hot.ajax(apiUri + "/delete", {
                    sessionId: id
                }, function (apiResult) {
                    if (apiResult.resultCode === 2000) {
                        hot.tip.success("操作成功", function () {
                            window.location.reload();
                        });
                    } else {
                        hot.tip.error("操作失败--" + apiResult.resultMsg);
                    }
                }, function () {
                }, "post", 300);
            })
        },
        stop: function (id) {
            hot.confirm("确定关闭该场直播", function () {
                hot.ajax(apiUri + "/stop", {
                    sessionId: id
                }, function (apiResult) {
                    if (apiResult.resultCode === 2000) {
                        hot.tip.success("操作成功", function () {
                            window.location.reload();
                        });
                    } else {
                        hot.tip.error("操作失败--" + apiResult.resultMsg);
                    }
                }, function () {
                }, "post", 300);
            });
        }
    }
</script>
</body>

</html>